<div class="formbody">
    <div class="formtitle">
        <span>批量生成充值卡</span>
    </div>
    <form id="rechargecardForm" action="" method="post" accept-charset="utf-8" target="_blank">
        <ul class="forminfo">
            <li>
                <label>面值:</label>
                <input type="number" min="0" name="amount" value="10" class="dfinput">
                <i>元
            </li>
            <li>
                <label>张数:</label>
                <input type="number" max="1000" min="0" name="count" value="100" class="dfinput">
                <i>张(一次最多1000张)</i>
            </li>
            <li>
                <label>&nbsp;</label>
                <input type="hidden" name="download" value="1">
                <input name="submit" type="submit"  class="btn" value="生成并下载">
            </li>
        </ul>
    </form>
    <script>
    window.onload = function(){
        var form = document.getElementById('rechargecardForm');
        form.onsubmit = function(){
            console.log(this,this.amount,this.count,this.submit);
            if( this.amount.value < 0 ){
                alert('面值必须大于0');
                return false;
            }
            if( this.count.value <0 || this.count.value>1000  ){
                alert('张数必须在1至1000张');
                return false;
            }
            $tips = '确定生成'+this.count.value+'张面值为'+this.amount.value+'元的充值卡?';
            if( ! confirm(tips) ){
                return false;
            }
        }
    }
    </script>
</div>